/*
 *	Audio Support
 *
 * Depends on SDL_mixer, which should be included with SDL.
 *	Relies on SDL being initialized with SDL_INIT_AUDIO first.
 *
 *  This is (obviously) a work in progress...
 */

#ifndef _AUDIO_H_
#define _AUDIO_H_

#include "config.h"

#ifdef __AUDIO_SDL__

#include <SDL_mixer.h>

#include "wtftypes.h"
#include "data.h"
#include "mm.h"

namespace WtfAudio {

	/* An AudioSample holds audio data that can be played back by the mixer.
	 * Formats supported for loading are WAV, OGG, MP3, MOD and MIDI provided
	 * they were enabled in your SDL. (We should probably use OGG) */
	class AudioSample : public WtfEngine::DataObject
	{
		private:
			bool loaded;
			Mix_Chunk *Data;
			int channel;


		public:
			AudioSample(const WtfEngine::String &name = "Unnamed audio sample");
			~AudioSample();

			bool isLoaded() { return loaded; };
			void setVolume(double volume);
			void Play();
			
			static AudioSample * Load(const WtfEngine::String& sFilePath);
			
			// TODO: Add real size here
			DATA_LOADABLE(AudioSample, sizeof(AudioSample))
	};

	/* AudioMixer provides an interface for methods that are not specific
	 * to any one sample */
	class AudioMixer : public WtfEngine::Singleton<AudioMixer>, public WtfEngine::Loggable<AudioMixer>
	{
		public:
			AudioMixer();
			~AudioMixer();
			
			// XXX - note this design may change in future
			//void PlaySample(AudioSample& sample);

		private:
			
	};

	class TestSample : public AudioSample
	{
		public:
		TestSample();
	};

};

#elif defined(__AUDIO_OPENAL__)
#	include "audio_openal.h"
#endif

namespace WtfAudio {
	void ExportScripting();
};

#endif /* _AUDIO_H_ */
